<template>
  <div class="single-check">
    <div class="check-box-wrapper" @click.stop="checkCurrentBox(1)">
      <span class="left-check-icon" :class="{'check-left-check-icon':isChecked1}"></span>
      <p class="right-text">{{nameList[0]}}</p>
    </div>
    <div class="check-box-wrapper" @click.stop="checkCurrentBox(2)">
      <span class="left-check-icon" :class="{'check-left-check-icon':isChecked2}"></span>
      <p class="right-text">{{nameList[1]}}</p>
    </div>
  </div>
</template>

<script>
  export default {
    name: "",
    props:{
      nameList: {
        type:Array,
        default:function(){
          return ['均次','人次'];
        }
      }
    },
    data(){
      return{
        value: '',
        isChecked1:true,
        isChecked2:false
      }
    },
    mounted(){

    },
    methods: {
      checkCurrentBox(type){
        if(type==1){
          this.isChecked1 = !this.isChecked1;
          this.isChecked2 = false;
        }else{
          this.isChecked2 = !this.isChecked2;
          this.isChecked1 = false;
        }
        this.$emit('singleCheck',type)
      }
    }
  }
</script>

<style scoped>
  .single-check{
    overflow:hidden;
    float:left;
  }
  .left-check-icon {
    width: 14px;
    height: 14px;
    display: inline-block;
    background-image: url("./check-box/no_checkmark.png");
    position:relative;
    top:1px
  }

  .check-left-check-icon {
    width: 14px;
    height: 14px;
    display: inline-block;
    background-image: url("./check-box/checkmark.png");
    position:relative;
    top:1px;
  }

  .right-text {
    display: inline-block;
    margin-left: 5px;
  }

  .check-box-wrapper {
    height: 30px;
    line-height: 30px;
    float:left;
    cursor:pointer;
    margin-right:10px;
  }
</style>
